package com.iweb.utils;

import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class EntityUtil {

    public static <T> List<T> copyPropertiesToList(List<?> list, Class cls) throws InstantiationException, IllegalAccessException {
        List<T> data = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            Object o = list.get(i);
            T t = (T) cls.newInstance(); // 反射
            BeanUtils.copyProperties(o, t);
            data.add(t);
        }
        return data;
    }

}
